<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "yyh_recall".
 *
 * @property int $id
 * @property int $patient_id 患者
 * @property int $user_id 员工
 * @property string $content 内容
 * @property string $kinds 类型
 * @property string|null $ordertime 最新预约时间
 * @property string|null $lastordertime 上次预约时间
 * @property string $createtime 创建时间
 */
class Recall extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'yyh_recall';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['patient_id', 'user_id', 'content', 'kinds', 'createtime'], 'required'],
            [['patient_id', 'user_id'], 'integer'],
            [['content', 'kinds'], 'string'],
            [['ordertime', 'lastordertime', 'createtime'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'patient_id' => '患者',
            'user_id' => '员工',
            'content' => '内容',
            'kinds' => '类型',
            'ordertime' => '最新预约时间',
            'lastordertime' => '上次预约时间',
            'createtime' => '创建时间',
        ];
    }

    public function getUsername()
    {
        return User::findOne($this->user_id)->showname;
    }
}
